package com.model;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

public class CreateTabelDokumen {

    public static void main(String[] args) {

        String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
        String userid = "hr"; // gantikan dengan username anda
        String password = "aga"; // gantikan dengan password anda
        Connection conn;      

        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            Statement statement=conn.createStatement();
            System.out.println("Koneksi is OK");


            String sql2 = "CREATE TABLE DOKUMEN("
                + "NO_DOKUMEN VARCHAR2(10),"
                +"PERIHAL VARCHAR2(50),"
                +"ASAL_DOKUMEN VARCHAR2(100),"
                +"PENERIMA_DOKUMEN VARCHAR2(100),"
                +"RUANG VARCHAR2(50),"
                +"LEMARI VARCHAR2(10),"
                +"LOKER VARCHAR2(10), "
                +"PETUGAS_PENERIMA VARCHAR2(50),"
                +"TGL_MASUK DATE,"
                +"TIPE_FILE VARCHAR2(10),"
                +"STATUS VARCHAR2(10),"
                +"CONSTRAINT DOKUMEN_PK PRIMARY KEY (NO_DOKUMEN,PERIHAL,ASAL_DOKUMEN) ENABLE)";
                    statement.executeUpdate(sql2);
//            String sql3 = " CREATE TABLE PINJAMAN(ID_ANGGOTA VARCHAR2(10),"
//                + "ID_KOLEKSI VARCHAR2(10),TGL_PINJAM DATE,TGL_KEMBALI DATE,"
//                + "CONSTRAINT PINJAMAN_PK PRIMARY KEY (ID_ANGGOTA, ID_KOLEKSI) ENABLE,"
//                + "CONSTRAINT PINJAMAN_FK1 FOREIGN KEY (ID_ANGGOTA)"
//                + "REFERENCES ANGGOTA (ID_ANGGOTA) ON DELETE CASCADE ENABLE,"
//                + "CONSTRAINT PINJAMAN_FK2 FOREIGN KEY (ID_KOLEKSI) "
//                + "REFERENCES PUBLIKASI (ID_KOLEKSI) ON DELETE CASCADE ENABLE )";
//                    statement.executeUpdate(sql3);
       } catch (SQLException e) {
        // perform error handling here
            System.out.println("error :"+ e.getMessage());
}

    }
}
